LanguageExt.Core

LanguageExt.Core Type Classes

If you're new to this library or functional-programming this is almost certainly not the place to start browsing!

Type-classes try to replicate the traites of Haskell in C#. They pair with the class-instances using ad-hoc polymorphism.

Ad-hoc polymorphism has long been believed to not be possible in C#. However with some cunning it is. Ad-hoc polymorphism allows programmers to add traits to a type later. For example in C# it would be amazing if we had an interface called INumeric for numeric types like int, long, double, etc. The reason this doesn't exist is if you write a function like:

INumeric Add(INumeric x, INumeric y) => x + y;

Then it would cause boxing. Which is slow (well, slower). I can only assume that's why it wasn't added by the BCL team. Anyway, it's possible to create a numeric type, very much like a trait in Haskell, and ad-hoc instances of the numeric trait that allow for generic numeric operations without boxing. See the wiki for a deeper dive into ad-hoc polymorphism

Contents

Sub modules

Arithmetic
Bool
Choice
Const
Floating
Fraction
Indexable
Liftable
Num
Optional
Predicate

interface Trait Source #

class TraitAttribute Source #

Fields

field string NameFormat Source #

Constructors

constructor TraitAttribute (string nameFormat) Source #